From a8c0597626e850518f5f7988402211b8656aa1a4 Mon Sep 17 00:00:00 2001 From: Jimi Xenidis Date: Wed, 23 Aug 2006 05:44:46 -0400 Subject: [PATCH] [XEN][POWERPC] show symbols in backtrace This was already there, just had to hook it up. Signed-off-by: Jimi Xenidis Signed-off-by: Hollis Blanchard --- .hgignore | 2 ++ xen/arch/powerpc/Makefile | 18 +++++++++++++++--- xen/arch/powerpc/backtrace.c | 33 ++++++++++++++++----------------- xen/include/asm-powerpc/types.h | 19 ++++++++++++------- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/.hgignore b/.hgignore index 7625f4fa58..c1abfefb4a 100644 --- a/.hgignore +++ b/.hgignore @@ -203,6 +203,8 @@ ^xen/arch/powerpc/firmware$ ^xen/arch/powerpc/firmware_image$ ^xen/arch/powerpc/xen\.lds$ +^xen/arch/powerpc/.xen-syms$ +^xen/arch/powerpc/xen-syms.S$ ^unmodified_drivers/linux-2.6/\.tmp_versions ^unmodified_drivers/linux-2.6/.*\.cmd$ ^unmodified_drivers/linux-2.6/.*\.ko$ diff --git a/xen/arch/powerpc/Makefile b/xen/arch/powerpc/Makefile index 86f8fecf67..0a338a96dd 100644 --- a/xen/arch/powerpc/Makefile +++ b/xen/arch/powerpc/Makefile @@ -95,8 +95,20 @@ boot_of.o: CFLAGS += -DCMDLINE="\"$(IMAGENAME) $(CMDLINE)\"" start.o: boot/start.S $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@ -$(TARGET)-syms: start.o $(ALL_OBJS) xen.lds - $(CC) $(CFLAGS) $(OMAGIC) -Wl,-Ttext,$(xen_link_base),-T,xen.lds start.o $(ALL_OBJS) -o $@ +TARGET_OPTS = $(OMAGIC) -Wl,-Ttext,$(xen_link_base),-T,xen.lds +TARGET_OPTS += start.o $(ALL_OBJS) + +.xen-syms: start.o $(ALL_OBJS) xen.lds + $(CC) $(CFLAGS) $(TARGET_OPTS) -o $@ + +xen-syms.S: .xen-syms + $(CROSS_COMPILE)nm --synthetic -n $^ | $(BASEDIR)/tools/symbols > $@ + +xen-syms.o: xen-syms.S + $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@ + +$(TARGET)-syms: start.o $(ALL_OBJS) xen-syms.o xen.lds + $(CC) $(CFLAGS) $(TARGET_OPTS) xen-syms.o -o $@ $(TARGET).bin: $(TARGET)-syms $(CROSS_COMPILE)objcopy --output-target=binary $< $@ @@ -126,4 +138,4 @@ dom0.bin: $(DOM0_IMAGE) clean:: $(MAKE) -f $(BASEDIR)/Rules.mk -C of_handler clean - rm -f firmware firmware_image dom0.bin + rm -f firmware firmware_image dom0.bin .xen-syms diff --git a/xen/arch/powerpc/backtrace.c b/xen/arch/powerpc/backtrace.c index 2f4348cebf..da00ccdc0d 100644 --- a/xen/arch/powerpc/backtrace.c +++ b/xen/arch/powerpc/backtrace.c @@ -13,6 +13,9 @@ #include #include #include +#include + +static char namebuf[KSYM_NAME_LEN+1]; /* Shamelessly lifted from Linux Xmon try to keep pristene */ #ifdef __powerpc64__ @@ -69,36 +72,32 @@ static int mread(unsigned long adrs, void *buf, int size) static void get_function_bounds(unsigned long pc, unsigned long *startp, unsigned long *endp) { - *startp = pc; - *endp = pc; + unsigned long size, offset; + const char *name; + + *startp = *endp = 0; + if (pc == 0) + return; + + name = symbols_lookup(pc, &size, &offset, namebuf); + if (name != NULL) { + *startp = pc - offset; + *endp = pc - offset + size; + } } /* Print an address in numeric and symbolic form (if possible) */ static void xmon_print_symbol(unsigned long address, const char *mid, const char *after) { - char *modname; const char *name = NULL; unsigned long offset, size; printf(REG, address); -#if 0 - if (setjmp(bus_error_jmp) == 0) { - catch_memory_errors = 1; - sync(); - name = kallsyms_lookup(address, &size, &offset, &modname, - tmpstr); - sync(); - /* wait a little while to see if we get a machine check */ - __delay(200); - } - catch_memory_errors = 0; -#endif + name = symbols_lookup(address, &size, &offset, namebuf); if (name) { printf("%s%s+%#lx/%#lx", mid, name, offset, size); - if (modname) - printf(" [%s]", modname); } printf("%s", after); } diff --git a/xen/include/asm-powerpc/types.h b/xen/include/asm-powerpc/types.h index 4260cd0fa3..aab8d17e6d 100644 --- a/xen/include/asm-powerpc/types.h +++ b/xen/include/asm-powerpc/types.h @@ -3,8 +3,18 @@ #ifndef _PPC_TYPES_H #define _PPC_TYPES_H -typedef unsigned short umode_t; +#include +#if defined(__ppc__) +#define BYTES_PER_LONG 4 +#define BITS_PER_LONG 32 +#elif defined(__PPC64__) +#define BYTES_PER_LONG 8 +#define BITS_PER_LONG 64 +#endif + +#ifndef __ASSEMBLY__ +typedef unsigned short umode_t; /* * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the @@ -31,8 +41,6 @@ typedef unsigned long __u64; #endif #endif -#include - typedef signed char s8; typedef unsigned char u8; @@ -45,14 +53,10 @@ typedef unsigned int u32; #if defined(__ppc__) typedef signed long long s64; typedef unsigned long long u64; -#define BYTES_PER_LONG 4 -#define BITS_PER_LONG 32 typedef unsigned int size_t; #elif defined(__PPC64__) typedef signed long s64; typedef unsigned long u64; -#define BYTES_PER_LONG 8 -#define BITS_PER_LONG 64 typedef unsigned long size_t; #endif @@ -66,4 +70,5 @@ typedef u64 dma64_addr_t; typedef unsigned short xmem_bufctl_t; +#endif /* __ASSEMBLY__ */ #endif -- 2.30.2